package com.example.campus.controller.admin;

import com.example.campus.pojo.dto.CommentPageQueryDTO;
import com.example.campus.result.PageResult;
import com.example.campus.result.Result;
import com.example.campus.service.CommentService;
import com.example.campus.utils.constant.MessageConstant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("adminCommentController")
@RequestMapping("/admin/comment")
@Slf4j
@Api(tags = "管理端评论相关接口")
public class CommentController {

    @Autowired
    private CommentService commentService;

    @GetMapping("/list")
    @ApiOperation("评论信息分页查询")
    public Result<PageResult> commentList(CommentPageQueryDTO commentPageQueryDTO) {
        PageResult pageResult = commentService.getCommentList(commentPageQueryDTO);
        return Result.success(pageResult, MessageConstant.GET_LIST_SUCCESS);
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除评论")
    public Result deleteComment(@PathVariable Long id) {
        commentService.deleteById(id);
        return Result.success(MessageConstant.DELETE_SUCCESS);
    }
}
